package direct;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import util.ConnectionUtil;

import java.io.IOException;

/**
 * @program: rabbitmq-demo1
 * @description: direct 直连类型交换机
 * @author: luolidong
 * @create: 2021-06-27 19:23
 * @version: 1.0
 */
public class Provider {
    public static void main(String[] args) throws IOException {
        Connection connection = ConnectionUtil.createConnection();
        Channel channel = connection.createChannel();
//        direct 直连
        channel.exchangeDeclare("myExchange2", "direct");
        // direct 直连 routingKey指定路由key
        channel.basicPublish("myExchange2", "info",
                null, "info 信息1".getBytes());
        channel.basicPublish("myExchange2", "info",
                null, "info 信息2".getBytes());

        channel.basicPublish("myExchange2", "error",
                null, "error 信息2".getBytes());

        ConnectionUtil.closeConnectionChannel(channel, connection);
    }
}
